xend: Fix xm pci commands for inactive managed domains.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 19 May 2009 01:23:32 +0000 (02:23 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 19 May 2009 01:23:32 +0000 (02:23 +0100)
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/main.py

index c4da7fba7979d7b30826fab397fbcf3ec4c1e55c..7723a355a5b43bf957354eb070ec5dcedfdfcaf1 100644 (file)
@@ -621,9 +621,13 @@ class XendDomainInfo:
             pci_conf = self.info['devices'][dev_uuid][1]
             pci_devs = pci_conf['devs']
             for x in pci_devs:
-                if (int(x['vslot'], 16) == int(new_dev['vslot'], 16) and
-                   int(x['vslot'], 16) != AUTO_PHP_SLOT):
-                    raise VmError("vslot %s already have a device." % (new_dev['vslot']))
+                if x.has_key('vslot'):
+                    x_vslot = x['vslot']
+                else:
+                    x_vslot = x['requested_vslot']
+                if (int(x_vslot, 16) == int(new_dev['requested_vslot'], 16) and
+                   int(x_vslot, 16) != AUTO_PHP_SLOT):
+                    raise VmError("vslot %s already have a device." % (new_dev['requested_vslot']))
 
                 if (int(x['domain'], 16) == int(new_dev['domain'], 16) and
                    int(x['bus'], 16)    == int(new_dev['bus'], 16) and
@@ -710,14 +714,14 @@ class XendDomainInfo:
                 new_dev['bus'],
                 new_dev['slot'],
                 new_dev['func'],
-                new_dev['vslot'],
+                new_dev['requested_vslot'],
                 opts)
             self.image.signalDeviceModel('pci-ins', 'pci-inserted', bdf_str)
 
             vslot = xstransact.Read("/local/domain/0/device-model/%i/parameter"
                                     % self.getDomid())
         else:
-            vslot = new_dev['vslot']
+            vslot = new_dev['requested_vslot']
 
         return vslot
 
@@ -815,7 +819,10 @@ class XendDomainInfo:
                          int(x['bus'], 16) == int(dev['bus'], 16) and
                          int(x['slot'], 16) == int(dev['slot'], 16) and
                          int(x['func'], 16) == int(dev['func'], 16) ):
-                        vslot = x['vslot']
+                        if x.has_key('vslot'):
+                            vslot = x['vslot']
+                        else:
+                            vslot = x['requested_vslot']
                         break
                 if vslot == AUTO_PHP_SLOT_STR:
                     raise VmError("Device %04x:%02x:%02x.%01x is not connected"
@@ -1112,7 +1119,11 @@ class XendDomainInfo:
         #find the pass-through device with the virtual slot
         devnum = 0
         for x in pci_conf['devs']:
-            if int(x['vslot'], 16) == vslot:
+            if x.has_key('vslot'):
+                x_vslot = x['vslot']
+            else:
+                x_vslot = x['requested_vslot']
+            if int(x_vslot, 16) == vslot:
                 break
             devnum += 1
 
index a460bc8a3aba3e6e7d2ae01ef94923eab7570f4b..f33a74f9b6ac5a80f70da7c69e46d23a90fe4b9e 100644 (file)
@@ -2165,13 +2165,27 @@ def xm_pci_list(args):
     if len(devs) == 0:
         return
 
-    has_vslot = devs[0].has_key('vslot')
+    has_vslot = False
+    for x in devs:
+        if x.has_key('vslot'):
+            if x['vslot'] == "0x%s" % AUTO_PHP_SLOT_STR:
+                x['vslot'] = '-'
+            else:
+                has_vslot = True
+        elif not x.has_key('requested_vslot'):
+            x['vslot'] = '-'
+        elif x['requested_vslot'] == "0x%s" % AUTO_PHP_SLOT_STR:
+            x['vslot'] = '-'
+        else:
+            has_vslot = True
+            x['vslot'] = x['requested_vslot']
+
     if has_vslot:
         hdr_str = 'VSlt domain   bus   slot   func'
-        fmt_str =  "%(vslot)-3s    %(domain)-3s  %(bus)-3s   %(slot)-3s    %(func)-3s    "
+        fmt_str =  "%(vslot)-4s %(domain)-6s   %(bus)-4s  %(slot)-4s   %(func)-3s    "
     else:
         hdr_str = 'domain   bus   slot   func'
-        fmt_str =  "%(domain)-3s  %(bus)-3s   %(slot)-3s    %(func)-3s    "
+        fmt_str =  "%(domain)-6s   %(bus)-4s  %(slot)-4s   %(func)-3s    "
     hdr = 0
 
     for x in devs:
@@ -2457,7 +2471,7 @@ def parse_pci_configuration(args, state, opts = ''):
                 ['bus', '0x'+ pci_dev_info['bus']],
                 ['slot', '0x'+ pci_dev_info['slot']],
                 ['func', '0x'+ pci_dev_info['func']],
-                ['vslot', '0x%x' % int(vslot, 16)]]
+                ['requested_vslot', '0x%x' % int(vslot, 16)]]
         if len(opts) > 0:
             pci_bdf.append(['opts', opts])
         pci.append(pci_bdf)